﻿import store from '@/store'

export default {
	inserted(el, binding, vnode) {
		const {
			value
		} = binding
		const no_permission_array = store.getters && store.getters.no_permission_array
		if (value && typeof value === "string" && value.length > 0) {
			const permissionName = value
			const noPermission = no_permission_array.includes(permissionName)

			if (noPermission) {
				el.parentNode && el.parentNode.removeChild(el)
			}
		} else {
			throw new Error(`需要指明该功能名称! 如 v-permission="p-login"`)
		}
	}
}
